package server.workwithorder;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import abstractservlet.AbstractServlet;
import autoservice.api.controller.IAutoservice;
import controllers.Autoservice;

@WebServlet("/AddOrder")
public class AddOrder extends AbstractServlet {
	private static final String ADD_ORDER_PAGE = "/workwithorderpages/AddOrderPage.jsp";
	private static final String DELIMITER = " ";
	private static final String NUMBER = "number";
	private static final String FILLING_DATE = "fillingDate";
	private static final String BEGINNING_DATE = "beginningDate";
	private static final String DEADLINE_DATE = "deadlineDater";
	private static final String PRICE = "price";
	private static final String MASTER = "master";
	private static final String GARAGE = "garage";
	private static final String ADD_ORDER_OPERAT = "add order";
	private static final long serialVersionUID = 1L;
	private IAutoservice autoservice = Autoservice.getInstance();

	public AddOrder() {
		super();

	}

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		String parameters = request.getParameter(NUMBER) + DELIMITER
				+ request.getParameter(FILLING_DATE) + DELIMITER
				+ request.getParameter(BEGINNING_DATE) + DELIMITER
				+ request.getParameter(DEADLINE_DATE) + DELIMITER
				+ request.getParameter(PRICE) + DELIMITER
				+ request.getParameter(MASTER) + DELIMITER
				+ request.getParameter(GARAGE);
		super.navigate(request, response, ADD_ORDER_OPERAT, autoservice
				.addOrder(parameters).get(0), ADD_ORDER_PAGE);

	}

}
